package com.icloud.common.database.enums;

import lombok.Getter;


@Getter
public enum ArticleVisibleScopeEnum {
    ALL("ALL"), // 所有人可见
    HOME("HOME"), // 仅主页可见
    FORBIDDEN("FORBIDDEN"), // 不给他看
    STRANGER("STRANGER"), // 仅陌生人可见
    SQUARE("SQUARE"), // 仅动态广场可见
    SELF("SELF"); // 仅自己可见

    private final String code;

    ArticleVisibleScopeEnum(String code){
        this.code = code;
    }

    public static ArticleVisibleScopeEnum byCode(String code) {
        for (ArticleVisibleScopeEnum e: ArticleVisibleScopeEnum.values()) {
            if (e.code.equalsIgnoreCase(code)) {
                return e;
            }
        }
        return null;
    }

    public static boolean isAll(String code){
        return ALL.getCode().equalsIgnoreCase(code);
    }
    public static boolean isHome(String code){
        return HOME.getCode().equalsIgnoreCase(code);
    }
    public static boolean isForbidden(String code){
        return FORBIDDEN.getCode().equalsIgnoreCase(code);
    }
    public static boolean isStranger(String code){
        return STRANGER.getCode().equalsIgnoreCase(code);
    }
    public static boolean isSquare(String code){
        return SQUARE.getCode().equalsIgnoreCase(code);
    }
    public static boolean isSelf(String code){
        return SELF.getCode().equalsIgnoreCase(code);
    }
}
